﻿using Coldairarrow.Business.Frontstage.Valickets;
using Coldairarrow.Entity.Frontstage.Valickets;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Frontstage.Valickets
{
    [Route("/Frontstage/Valickets/[controller]/[action]")]
    public class BS_UserVailTicketController : BaseApiController
    {
        #region DI

        public BS_UserVailTicketController(IBS_UserVailTicketBusiness bS_UserVailTicketBus)
        {
            _bS_UserVailTicketBus = bS_UserVailTicketBus;
        }

        IBS_UserVailTicketBusiness _bS_UserVailTicketBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<BS_UserVailTicket>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _bS_UserVailTicketBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<BS_UserVailTicket> GetTheData(IdInputDTO input)
        {
            return await _bS_UserVailTicketBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(BS_UserVailTicket data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _bS_UserVailTicketBus.AddDataAsync(data);
            }
            else
            {
                await _bS_UserVailTicketBus.UpdateDataAsync(data);
            }
        }

        /// <summary>
        /// 前台——个人中心用户兑换优惠券
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task UserChangeTicket(ChangeTInput input)
        {
            await _bS_UserVailTicketBus.ChangeTicket(input);
        }

        /// <summary>
        /// 前台——个人中心用户优惠券列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetsMyTicket(GetTicketInput input)
        {
            return await _bS_UserVailTicketBus.GetMyTicket(input);
        }
        #endregion
    }
}